
/*
 * 旋转朝上，引脚正对人：
电位器，中间为模拟输入，左为GND，右为+5v
中间接A0
左旋转，逐渐减为0
右旋转，逐渐增加到1023
*/
const int led = 3; // LED接2号

void setup() {
  Serial.begin(9600);
  pinMode(led, OUTPUT);
}

void loop() {
  unsigned int brightness = analogRead(A0);
  Serial.println(brightness);
  unsigned int lig = map(brightness,0,1023,0,255); // 将0~1023的值，映射为0~255输出PWM
  analogWrite(led, lig);
  delay(100);
}
